using System.IO;
using System.Xml;
using System.Xml.Schema;

namespace CriticalSystems.Instrumentation.Internal
{
    internal static class SchemaValidationHelper
    {
        public const string SystemInformationSchema = "CriticalSystems.Instrumentation.CriticalSystems.Instrumentation.xsd";

        public static XmlReader GetValidatingReader(string schemaResource, Stream xmlStream)
        {
            var schemas = new XmlSchemaSet();
            schemas.Add(XmlSchema.Read(ResourceUtilities.GetEmbeddedResource(schemaResource), null));
            var settings = new XmlReaderSettings {Schemas = schemas, ValidationType = ValidationType.Schema};
            var reader = XmlReader.Create(xmlStream, settings);
            return reader;
        }
    }
}